<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div id="test">
			<h2>显示格式化的日期时间</h2>
			<p>{{date}}</p>
			<p>完整版: {{date | dateString}}</p>
			<p>年月日: {{date | dateString("YYYY-MM-DD")}}</p>
			<p>时分秒: {{date | dateString("HH:mm:ss")}}</p>
		</div>
		
		<script type="text/javascript" src="js/vue.js"></script>
		<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.js"></script>
		<script>
			// 自定义过滤器
			Vue.filter("dateString",function(value, format){
				
				return moment(value).format(format || "YYYY-MM-DD HH:mm:ss")
			})
			
			new Vue({
				el: "#test",
				data: {
					date: new Date()
				}
			})
		</script>
	</body>
</html>
